Imports CapaDeDatos
Public Class nRemito
    Public Remito As CapaDeDatos.dRemito = New CapaDeDatos.dRemito
    Public Proveedor As CapaDeDatos.dProveedor = New CapaDeDatos.dProveedor
    Public Condicion As CapaDeDatos.dCondicion = New CapaDeDatos.dCondicion
    Public Function InsertarRemito(ByVal Fecha As String, ByVal Numero As String, ByVal CodigoProveedor As Integer, ByVal Cantidad As Integer, _
                                   ByVal Estado As String, ByVal Observacion As String, ByVal CondicionCompra As String) As Integer
        Return Remito.Insertar(Fecha, Numero, CodigoProveedor, Cantidad, Estado, Observacion, CondicionCompra)
    End Function
    Public Function ExisteRemito(ByVal Numero As String, ByVal CodigoProveedor As Integer) As Boolean
        Return Remito.Existe(Numero, CodigoProveedor)
    End Function
    Public Function ModificarRemito(ByVal CodigoRemito As Integer, ByVal Estado As String, ByVal Factura As Integer) As Boolean
        Return Remito.Modificar(CodigoRemito, Estado, Factura)
    End Function
    Public Function EliminarRemito(ByVal CodigoRemito As Integer) As Boolean
        Return Remito.Eliminar(CodigoRemito)
    End Function

    Public Function ListarRemitos(ByVal CodigoRemito As Integer, ByVal Fecha As String, ByVal Numero As String, _
                                 ByVal CodigoProveedor As Integer, ByVal Cantidad As Integer, ByVal Estado As String, ByVal Observacion As String, ByVal CondicionCompra As String) As DataSet
        Return Remito.BuscarFiltrado(CodigoRemito, Fecha, Numero, CodigoProveedor, Cantidad, Estado, Observacion, CondicionCompra)
    End Function
    Public Function ListarTodos(ByVal CodigoRemito As Integer, ByVal Fecha As String, ByVal Numero As String, _
                                ByVal CodigoProveedor As Integer, ByVal Cantidad As Integer, ByVal Estado As String, ByVal Observacion As String, ByVal CondicionCompra As String) As DataSet
        Dim dtsPrincipal As DataSet
        dtsPrincipal = Remito.BuscarFiltrado(CodigoRemito, Fecha, Numero, CodigoProveedor, Cantidad, Estado, Observacion, CondicionCompra)
        dtsPrincipal.Tables(0).Columns.Add("RazonSocial")
        dtsPrincipal.Tables(0).Columns.Add("Descripcion")
        Dim i As Integer
        For i = 0 To dtsPrincipal.Tables(0).Rows.Count - 1
            Try
                dtsPrincipal.Tables(0).Rows(i)("RazonSocial") = Proveedor.BuscarFiltrado(dtsPrincipal.Tables(0).Rows(i)("CodigoProveedor").ToString(), "", "", "", "", "", "", "", "").Tables(0).Rows(0)("RazonSocial").ToString()
            Catch ex As Exception
                dtsPrincipal.Tables(0).Rows(i)("RazonSocial") = "Error, Razon Social no Encontrada"
            End Try
            Try
                dtsPrincipal.Tables(0).Rows(i)("Descripcion") = Condicion.BuscarFiltrado(dtsPrincipal.Tables(0).Rows(i)("CondicionCompra").ToString(), "", 0, "Compra").Tables(0).Rows(0)("Descripcion").ToString()
            Catch ex As Exception
                dtsPrincipal.Tables(0).Rows(i)("Descripcion") = "Contado"
            End Try
        Next
        Return dtsPrincipal
    End Function

End Class
